<?php
/**
  * FAQ 列表
  * faqList.php
  * 模板文件：faqList.html
  */
include_once("global.php");
include_once("functions/faq.class.php");
include_once("include/pages.inc.php");

//init object
$faq = new faq;
$faqSql = new faqSql;
$Pages = new pages();
$faqTypeArr = $GLOBAL["DATA"]->faqType;

//$DB->debug = true;
//get request
$act		= $_REQUEST["act"];				//action search or delete
$fiType		= $_REQUEST["fiType"];			//查询类型
$keyword	= trim($_REQUEST["keyword"]);	//查询关键字
$fiId 		= $_REQUEST["fiid"];			//faq id 删除时用到
//del
if($act == "del"){
	if($faq->del($fiId)){//删除成功，跳转到当前页面
		$referurl = $_SERVER['HTTP_REFERER'];
		header("location:$referurl");
	}
}
//sql参数.这里是查询条件
$parArr = array(
	"fi_type"	=> $fiType,
	"keyword"	=> $keyword,
	);
//(错误)提示信息
$errmsg = "";

//get result
//设置每页显示记录数
$Pages->lim = 10;
$Pages->query = $faq->getSql($parArr);
$Pages->Pages();
$aryResult = $Pages->check();
//取得结果集
$rs = $aryResult[0];
//取得结果数
$intCount= $aryResult[2];
//取得分页HTML字串
$pageStr = $aryResult[3];

while(!$rs->EOF){
	$rsList[] = array(
			"id"		=> $rs->fields["fi_id"],
			"question"	=> $rs->fields["fi_question"], 
			"reply"		=> $rs->fields["fi_reply"],
			"type"		=> $faqTypeArr[$rs->fields["fi_type"]],//faq类别
			"datein"	=> $rs->fields["fi_datein"],			
			);
	$rs->MoveNext();
}



//template init
$smarty = $COMMON->template_init();

$smarty->assign(array(
			"errmsg"		=> $errmsg,
			"rsList"		=> $rsList,
			"pageStr"		=> $pageStr,
			"fitypeOption"	=> $COMMON->getOptionsString($GLOBAL["DATA"]->faqType, $fiType),
			"keyword"		=> $keyword,	
		));

$smarty->display("faqList.html");
?>